package com.weu.service.impl;

import com.weu.bean.CarModel;
import com.weu.bean.Result;
import com.weu.mapper.CarModelMapper;
import com.weu.service.IModelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ModelServiceImpl implements IModelService {

    @Resource
    private CarModelMapper carModelMapper;

    @Override
    public List<CarModel> getAll() {
        return carModelMapper.getAll();
    }

    @Override
    public CarModel getOne(int id) {
        return carModelMapper.getOne(id);
    }

    @Override
    public Result getBySeriesId(int id) {
        Result result = new Result();
        result.setSuccess(true);
        result.setMsg("获取系列数据成功");
        List<CarModel> carModelList = carModelMapper.getBySeriesId(id);
        result.setDetail(carModelList);
        return result;
    }

    @Override
    public int delById(int id) {
        return carModelMapper.delById(id);
    }

    @Override
    public int updateModel(CarModel carModel) {
        return carModelMapper.updateModel(carModel);
    }

    @Override
    public int saveModel(CarModel carModel) {
        return carModelMapper.saveModel(carModel);
    }
}
